<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //类型检测:typeof
        let a1='靓仔';
        console.log("类型检测："+typeof(a1));//类型检测：string

        //String字符类型
        let a2='ABCdef qwE '
        //获取长度
        console.log("获取长度:"+a2.length);//获取长度:10
        //大小写转换
        console.log("转换成大写:"+a2.toUpperCase());//转换成大写:ABCDEF QWE
        console.log("转换成小写:"+a2.toLowerCase());//转换成小写:abcdef qwe
        //移除左右空白
        console.log("移除左右空白:"+a2.trim().length);//移除左右空白:10
        //获取单个字符
        console.log("获取单个字符:"+a2.charAt(2));//获取单个字符:C
        //截取字符串
        console.log("slice截取字符串:"+a2.slice(3,5));//de   左闭右开
        console.log("subString截取字符串:"+a2.substring(3,5));//subString截取字符串:de
        console.log("subString截取字符串:"+a2.substring(3,0));//ABC 较小的做为起始位置
        console.log("substr截取字符串:"+a2.substr(3,3));//def 从下标为3开始，向后截取3个
        //查
        console.log("indexOf查："+a2.indexOf('o'));//-1
        console.log("indexOf查："+a2.indexOf('C'));//2

        console.log("lastIndexOf查："+a2.lastIndexOf('o'));//-1
        console.log("lastIndexOf查："+a2.lastIndexOf('C'));//2

    </script>
</body>
</html>